package com.jl.driver.vritual.ternimal;

import opencard.core.terminal.CardTerminalException;
import opencard.core.terminal.CardTerminalFactory;
import opencard.core.terminal.CardTerminalRegistry;
import opencard.core.terminal.TerminalInitException;

public class VirtualTerminalFactory implements CardTerminalFactory {

	public VirtualTerminalFactory() throws CardTerminalException {
		super();
	}

	@Override
	public void close() throws CardTerminalException {
	}

	@Override
	public void createCardTerminals(CardTerminalRegistry ctr, String[] args)
			throws CardTerminalException, TerminalInitException {
		String name = args[TERMINAL_NAME_ENTRY];
		String type = args[TERMINAL_TYPE_ENTRY];
		String address = args[TERMINAL_ADDRESS_ENTRY];
		String baudrate = args[TERMINAL_ADDRESS_ENTRY + 1];
		String timeout = args[TERMINAL_ADDRESS_ENTRY + 2];

		if (args[TERMINAL_TYPE_ENTRY].equals("ComCard")) {
			ComPortTernimal card = new ComPortTernimal(
					name + "[" + type + "-" + address + "]", type, address,
					baudrate, timeout);
			ctr.add(card);
		}
	}

	@Override
	public void open() throws CardTerminalException {

	}

}
